﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Universum.Infrastructure.Persistence;
using Moq;
using Universum.Model.Domain.Blogs;

namespace Universum.Unit.Tests.Controllers.BlogsControllerBehaviours
{
	public class with_user_logged_and_blog_with_100_posts : with_user_logged
	{
		public Mock<IRepository> RepositoryMock;
		public IRepository Repository;
		protected override void EstablishContext()
		{
			base.EstablishContext();
			var blog = new Blog
			{
				ID = Guid.NewGuid(),
				Owner = Principal.Identity.Name
			};
			var blogArticles = new BlogArticle[100];
			for (int i = 0; i < 100; i++)
			{
				blogArticles[i] = new BlogArticle
				{
					Text = "un text pentru articolul " + i,
					Title = "articolul " + i,
					ID = Guid.NewGuid(),
					BlogId = blog.ID
				};
			}

			RepositoryMock = new Mock<IRepository>();

			RepositoryMock.Setup(r => r.Query(It.IsAny<
				Universum.Infrastructure.Persistence.Queries.Blog.BlogArticleByBlogId>()))
				
				.Returns(
				() => blogArticles.AsQueryable()
				);
			RepositoryMock.Setup(r => r.Query(It.IsAny<
							Universum.Infrastructure.Persistence.Queries.Blog.BlogByOwner>()))
							.Returns(() => new Blog[] { blog }.AsQueryable());
			Repository = RepositoryMock.Object;
		}



	}
}
